package com.itheima.hello.hellopromax高级进阶.接口;

import java.util.ArrayList;

public class studentImpl2 implements studentOp{
    @Override
    public void printAllinfo(ArrayList<student> student) {
        int counter1 = 0;
        int counter2 = 0;
        System.out.println("--------------班级成员全部信息-----------");
        for (int i = 0; i < student.size(); i++) {
            System.out.println("姓名:"+ student.get(i).getName() + ",性别:" + student.get(i).getSex() + ",成绩:" + student.get(i).getScore());
            if (student.get(i).getSex() == '男'){
                counter1++;
            }else {
                counter2++;
            }}
        System.out.println("--------------------------------------");
        System.out.println("全班总人数为:" + student.size());
        System.out.println("男生人数为:" + counter1 + ",女生人数为:" + counter2);}

    @Override
    public void printavgscore(ArrayList<student> student) {
            double allscores = 0.0;
            double max = student.get(0).getScore();
            double min = student.get(0).getScore();
            System.out.println("-----------------班级平均分-------------");
            for (int i = 0; i < student.size(); i++) {
                allscores += student.get(i).getScore();
                if (student.get(i).getScore() > max){
                    max = student.get(i).getScore();
                }
                if (student.get(i).getScore() < min){
                    min = student.get(i).getScore();
                }}
            System.out.println("学生的最高分为:" + max);
            System.out.println("学生的最低分为:" + min);
            double avgscore = (allscores  - max - min)/ (student.size() - 2);
            System.out.println("全班的平均分为:" + avgscore);
}}